import type { VxeTableGridOptions } from '@vben/plugins/vxe-table';

import type { StepStandardModel } from '#/api/process/models';

/**
 * 获取表格列配置。
 */
export function useDrawerColumns(): VxeTableGridOptions<StepStandardModel>['columns'] {
  return [
    { type: 'seq', width: 60 },
    {
      field: 'parameterName',
      title: '参数名称',
      width: 160,
      editRender: { name: 'input' },
    },
    {
      field: 'parameterCode',
      title: '参数编码',
      width: 160,
      editRender: { name: 'input' },
    },
    {
      field: 'standardValue',
      title: '标准值',
      width: 100,
      editRender: { name: 'input' },
    },
    {
      field: 'tolerance',
      title: '偏差',
      width: 80,
      editRender: { name: 'input' },
    },
    {
      field: 'minLimit',
      title: '下限',
      width: 100,
      editRender: { name: 'input', attrs: { type: 'number' } },
    },
    {
      field: 'maxLimit',
      title: '上限',
      width: 100,
      editRender: { name: 'input', attrs: { type: 'number' } },
    },
    {
      field: 'measurementUnit',
      title: '单位',
      width: 90,
      editRender: { name: 'input' },
    },
    {
      field: 'inspectionMethod',
      title: '检测方法',
      minWidth: 100,
      editRender: { name: 'input' },
    },
    {
      field: 'symbol',
      title: '点位',
      width: 180,
      editRender: { name: 'input' },
    },
    {
      field: 'symbolIndex',
      title: '点位索引',
      width: 100,
      editRender: { name: 'input' },
    },
    {
      field: 'conversion',
      title: '倍率',
      width: 90,
      editRender: {
        name: 'select',
        options: [
          { label: '1', value: '1' },
          { label: '0.1', value: '0.1' },
          { label: '0.01', value: '0.01' },
          { label: '0.001', value: '0.001' },
          { label: '10', value: '10' },
          { label: '100', value: '100' },
          { label: '1000', value: '1000' },
        ],
      },
    },
    {
      field: 'digits',
      title: '小数位',
      width: 80,
      editRender: {
        name: 'select',
        options: [
          { label: '0', value: 0 },
          { label: '1', value: 1 },
          { label: '2', value: 2 },
          { label: '3', value: 3 },
          { label: '4', value: 4 },
          { label: '5', value: 5 },
        ],
      },
    },
    {
      field: 'action',
      title: '操作',
      fixed: 'right',
      width: 160,
      slots: { default: 'action' },
    },
  ];
}

/**
 * 获取表格列配置。
 */
export function useColumns(): VxeTableGridOptions<StepStandardModel>['columns'] {
  return [
    { type: 'seq', width: 60 },
    { field: 'parameterName', title: '参数名称', width: 160 },
    { field: 'parameterCode', title: '参数编码', width: 160 },
    { field: 'standardValue', title: '标准值', width: 100 },
    { field: 'tolerance', title: '偏差', width: 80 },
    { field: 'minLimit', title: '下限', width: 100 },
    { field: 'maxLimit', title: '上限', width: 100 },
    { field: 'measurementUnit', title: '单位', width: 90 },
    { field: 'inspectionMethod', title: '检测方法', minWidth: 100 },
    { field: 'symbol', title: '点位', width: 180 },
    { field: 'symbolIndex', title: '点位索引', width: 90 },
    { field: 'conversion', title: '倍率', width: 80 },
    { field: 'digits', title: '小数位', width: 80 },
  ];
}
